/**
*      author: Y_Yao
*      created: 2025-01-18 20:07:01
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 3e5 + 7;
int q;
int a[N],sum[N];


void solve()
{
    cin >> q;
    int cnt = 0;
    int i = 1;
    int s = 1;
    while(q--)
    {
        int o;
        cin >> o;
        if(o == 1)
        {
            int l;
            cin >> l;
            a[i] = l;
            sum[i] = sum[i-1] + a[i];
            i++;
        }
        else if(o == 2)
        {
            cnt += a[s];
            s++; 
        }
        else
        {
            int k;
            cin >> k;
            cout << sum[k - 1 + s - 1] - cnt << endl;
        }
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}